//
//  ZH_ScrollViewTitleTableViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/17.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_ScrollViewTitleTableViewCell.h"
@interface ZH_ScrollViewTitleTableViewCell()
@property (nonatomic,weak)UIImageView *leftImage;
@property (nonatomic,weak)UILabel *leftLabel;
@property (nonatomic,weak)UIView *lineView;
@property (nonatomic,weak)UILabel *contentLabel;
@property (nonatomic,weak)UIButton *moreButton;
@end
@implementation ZH_ScrollViewTitleTableViewCell

///创建
+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_ScrollViewTitleTableViewCell";
    ZH_ScrollViewTitleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_ScrollViewTitleTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
///初始化
-(void)initDefault
{
    [self unShowClickEffect];
}
- (void)loadSubviewConstraints{
    [self.leftImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(FITSCALE(12));
        make.top.equalTo(self.contentView).offset(FITSCALE(10));
        make.centerY.equalTo(self.contentView);
    }];
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.leftImage.mas_right).offset(FITSCALE(10));
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.height.mas_equalTo(FITSCALE(22));
        make.left.equalTo(self.leftLabel.mas_right).offset(FITSCALE(12));
        make.width.mas_equalTo(FITSCALE(2));
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.lineView.mas_right).offset(FITSCALE(7));
    }];
    [self.moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(FITSCALE(-22));
    }];
}
#pragma mark - getter,setter
- (UIImageView *)leftImage{
    if (!_leftImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_notice"];
        image.contentMode = UIViewContentModeScaleToFill;
        image.clipsToBounds = YES;
        [self.contentView addSubview:_leftImage = image];
    }
    return _leftImage;
}
- (UILabel *)leftLabel{
    if (!_leftLabel) {
        UILabel *label = [UILabel createLabelWithText:@"公告" font:kFontSize_34];
        label.font = [UIFont boldSystemFontOfSize:17];
        [self.contentView addSubview:_leftLabel = label];
    }
    return _leftLabel;
}
- (UIView *)lineView{
    if (!_lineView) {
        UIView *lineView = [UIView createViewWithBackgroundColor:[UIColor colorWithHexString:@"#DFDFDF"]];
        [self.contentView addSubview:_lineView = lineView];
    }
    return _lineView;
}
- (UILabel *)contentLabel{
    if (!_contentLabel) {
        UILabel *label = [UILabel createLabelWithText:@"公告标题, 公告标题..." font:kFontSize_26];
        [self.contentView addSubview:_contentLabel = label];
    }
    return _contentLabel;
}
- (UIButton *)moreButton{
    if (!_moreButton) {
        UIButton *button = [UIButton createNoBgButtonWithTitle:@"更多>>" target:self action:nil];
        [button setTitleColor:[UIColor colorWithHexString:@"#999999"] forState:UIControlStateNormal];
        [self.contentView addSubview:_moreButton = button];
    }
    return _moreButton;
}
@end
